fix compiler errors which caused by support of freebsd

This commit is contained in:
Jinhao 2018-05-21 17:07:24 +08:00
parent da70334459
commit 26ce77ded5
2 changed files with 18 additions and 17 deletions

View File

@ -12,8 +12,10 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
# ifndef NANA_LINUX
static bool get_default_audio(std::string &, bool); static bool get_default_audio(std::string &, bool);
# endif # endif
#endif
namespace nana{namespace audio namespace nana{namespace audio
{ {
@ -47,14 +49,13 @@ namespace nana{namespace audio
}wave_native_if; }wave_native_if;
#endif #endif
//class audio_device //class audio_device
audio_device::audio_device() audio_device::audio_device():
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS) || defined(NANA_LINUX)
: handle_(nullptr), buf_prep_(nullptr) handle_(nullptr),
#elif defined(NANA_POSIX) #elif defined(NANA_POSIX)
: handle_(-1), buf_prep_(nullptr) handle_(-1),
#elif defined(NANA_LINUX)
: handle_(nullptr), buf_prep_(nullptr)
#endif #endif
buf_prep_(nullptr)
{} {}
audio_device::~audio_device() audio_device::~audio_device()
@ -64,7 +65,7 @@ namespace nana{namespace audio
bool audio_device::empty() const bool audio_device::empty() const
{ {
#ifdef NANA_POSIX #if defined(NANA_POSIX) && not defined(NANA_LINUX)
return (-1 == handle_); return (-1 == handle_);
#else #else
return (nullptr == handle_); return (nullptr == handle_);
@ -249,11 +250,6 @@ namespace nana{namespace audio
wave_native_if.out_prepare(handle_, m, sizeof(WAVEHDR)); wave_native_if.out_prepare(handle_, m, sizeof(WAVEHDR));
wave_native_if.out_write(handle_, m, sizeof(WAVEHDR)); wave_native_if.out_write(handle_, m, sizeof(WAVEHDR));
#elif defined(NANA_POSIX)
// consider moving this to a background thread.
// currently this blocks calling thread.
::write(handle_, m->buf, m->bufsize);
buf_prep_->revert(m);
#elif defined(NANA_LINUX) #elif defined(NANA_LINUX)
std::size_t frames = m->bufsize / bytes_per_frame_; std::size_t frames = m->bufsize / bytes_per_frame_;
std::size_t buffered = 0; //in bytes std::size_t buffered = 0; //in bytes
@ -269,6 +265,11 @@ namespace nana{namespace audio
::snd_pcm_prepare(handle_); ::snd_pcm_prepare(handle_);
} }
buf_prep_->revert(m); buf_prep_->revert(m);
#elif defined(NANA_POSIX)
// consider moving this to a background thread.
// currently this blocks calling thread.
::write(handle_, m->buf, m->bufsize);
buf_prep_->revert(m);
#endif #endif
} }
@ -304,7 +305,7 @@ namespace nana{namespace audio
}//end namespace audio }//end namespace audio
}//end namespace nana }//end namespace nana
#ifdef NANA_POSIX #if defined(NANA_POSIX) && not defined(NANA_LINUX)
// parse input securely, no-overruns or overflows. // parse input securely, no-overruns or overflows.
static bool match(char *&cursor, const char *pattern, const char *tail) static bool match(char *&cursor, const char *pattern, const char *tail)
{ {

View File

@ -34,7 +34,7 @@ static void posix_open_url(const char *url_utf8)
const char *home = getenv("HOME"); const char *home = getenv("HOME");
std::string cheat(home); std::string cheat(home);
cheat += "/.mozilla"; cheat += "/.mozilla";
struct stat exists{}; struct stat exists;
// TODO: generalize this for chromium, opera, waterfox, etc. // TODO: generalize this for chromium, opera, waterfox, etc.
// Most desktop environments (KDE, Gnome, Lumina etc.) provide a way to set // Most desktop environments (KDE, Gnome, Lumina etc.) provide a way to set