diff options
author | japm48 <japm48@users.noreply.github.com> | 2020-10-20 13:21:52 +0200 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2020-10-20 09:37:52 -0400 |
commit | 465dea1e73006da6e45ea2eee3b2caab80a9490e (patch) | |
tree | ee1c532c6246c4913d447ee3567da23c36940709 /gr-audio/lib | |
parent | 44f6be7bf0e6764b20991384bdb4f0fa6e87c4e8 (diff) |
audio: fix Windows logging
This removes a few compilation errors in Windows related to logging
functions (see PR #3339).
Diffstat (limited to 'gr-audio/lib')
-rw-r--r-- | gr-audio/lib/windows/windows_sink.cc | 19 | ||||
-rw-r--r-- | gr-audio/lib/windows/windows_source.cc | 50 |
2 files changed, 40 insertions, 29 deletions
diff --git a/gr-audio/lib/windows/windows_sink.cc b/gr-audio/lib/windows/windows_sink.cc index 9c60265307..c7101b736e 100644 --- a/gr-audio/lib/windows/windows_sink.cc +++ b/gr-audio/lib/windows/windows_sink.cc @@ -178,8 +178,9 @@ int windows_sink::work(int noutput_items, // let's just fail and give some debugging information about the status of // the buffers. for (int i = 0; i < nPeriods; i++) { - GR_LOG_ERROR( - d_logger, "audio buffer %d: %d", i, d_buffers[i]->dwFlags); + GR_LOG_ERROR(d_logger, + boost::format("audio buffer %d: %d") % i % + d_buffers[i]->dwFlags); } GR_LOG_ERROR(d_logger, boost::format("no audio buffers available: %s") % @@ -343,11 +344,13 @@ int windows_sink::open_waveout_device(void) 0, CALLBACK_EVENT | WAVE_ALLOWSYNC); - if (result) + if (result) { GR_LOG_ERROR(d_logger, boost::format("Failed to open waveform output device. %s") % - strerr(errno)); - return -1; + strerror(errno)); + return -1; + } + return 0; } @@ -363,14 +366,16 @@ int windows_sink::write_waveout(LPWAVEHDR lp_wave_hdr) w_result = waveOutPrepareHeader(d_h_waveout, lp_wave_hdr, sizeof(WAVEHDR)); if (w_result != 0) { GR_LOG_ERROR(d_logger, - boost::format("Failed to waveOutPrepareHeader %s") % strerr(errno)); + boost::format("Failed to waveOutPrepareHeader %s") % + strerror(errno)); return -1; } w_result = waveOutWrite(d_h_waveout, lp_wave_hdr, sizeof(WAVEHDR)); if (w_result != 0) { GR_LOG_ERROR(d_logger, - boost::format("Failed to write block to device %s") % strerr(errno)); + boost::format("Failed to write block to device %s") % + strerror(errno)); switch (w_result) { case MMSYSERR_INVALHANDLE: GR_LOG_ERROR(d_logger, "Specified device handle is invalid"); diff --git a/gr-audio/lib/windows/windows_source.cc b/gr-audio/lib/windows/windows_source.cc index 465c62f028..fd7d3e44b7 100644 --- a/gr-audio/lib/windows/windows_source.cc +++ b/gr-audio/lib/windows/windows_source.cc @@ -89,9 +89,10 @@ windows_source::windows_source(int sampling_freq, const std::string device_name) d_chunk_size * wave_format.nChannels * (wave_format.wBitsPerSample / 8); // room for 16-bit audio on one channel. + gr::logger_ptr logger, debug_logger; if (open_wavein_device() < 0) { - GR_LOG_ERROR(d_logger, - boost::format("open_wavein_device() failed %s" % strerror(errno))); + GR_LOG_ERROR(logger, + boost::format("open_wavein_device() failed %s") % strerror(errno)); throw std::runtime_error("audio_windows_source:open_wavein_device() failed"); } else { GR_LOG_INFO(d_debug_logger, "Opened windows wavein device"); @@ -106,9 +107,9 @@ windows_source::windows_source(int sampling_freq, const std::string device_name) lp_buffer->lpData = new CHAR[d_buffer_size]; MMRESULT w_result = waveInPrepareHeader(d_h_wavein, lp_buffer, sizeof(WAVEHDR)); if (w_result != 0) { - GR_LOG_ERROR( - d_logger, - boost::format("Failed to waveInPrepareHeader %s" % strerror(errno))); + GR_LOG_ERROR(logger, + boost::format("Failed to waveInPrepareHeader %s") % + strerror(errno)); throw std::runtime_error("open_wavein_device() failed"); } waveInAddBuffer(d_h_wavein, lp_buffer, sizeof(WAVEHDR)); @@ -220,6 +221,8 @@ bool windows_source::is_number(const std::string& s) UINT windows_source::find_device(std::string szDeviceName) { + gr::logger_ptr logger, debug_logger; + UINT result = -1; UINT num_devices = waveInGetNumDevs(); if (num_devices > 0) { @@ -230,7 +233,7 @@ UINT windows_source::find_device(std::string szDeviceName) if (num < num_devices) { result = num; } else { - GR_LOG_WARN(d_logger, + GR_LOG_WARN(logger, boost::format("waveIn deviceID %d was not found, " "defaulting to WAVE_MAPPER") % num); @@ -242,10 +245,10 @@ UINT windows_source::find_device(std::string szDeviceName) for (UINT i = 0; i < num_devices; i++) { WAVEINCAPS woc; if (waveInGetDevCaps(i, &woc, sizeof(woc)) != MMSYSERR_NOERROR) { - GR_LOG_ERROR(d_logger, + GR_LOG_ERROR(logger, boost::format("Could not retrieve wave out device " - "capabilities for device %s" % - strerror(errno))); + "capabilities for device %s") % + strerror(errno)); return -1; } if (woc.szPname == szDeviceName) { @@ -264,9 +267,9 @@ UINT windows_source::find_device(std::string szDeviceName) } } } else { - GR_LOG_ERROR(d_logger, - boost::format("No WaveIn devices present or accessible: %s" % - strerror(errno))); + GR_LOG_ERROR(logger, + boost::format("No WaveIn devices present or accessible: %s") % + strerror(errno)); } return result; } @@ -276,6 +279,8 @@ int windows_source::open_wavein_device(void) UINT u_device_id; unsigned long result; + gr::logger_ptr logger, debug_logger; + /** Identifier of the waveform-audio output device to open. It can be either a device identifier or a handle of an open waveform-audio input device. You can use the following flag @@ -301,10 +306,10 @@ int windows_source::open_wavein_device(void) char err_msg[50]; waveInGetErrorText(supported, err_msg, 50); GR_LOG_INFO(d_debug_logger, boost::format("format error: %s") % err_msg); - GR_LOG_ERROR( - d_logger, - boost::format("Requested audio format is not supported by device driver: %s" % - strerror(errno))); + GR_LOG_ERROR(logger, + boost::format( + "Requested audio format is not supported by device driver: %s") % + strerror(errno)); return -1; } @@ -317,9 +322,9 @@ int windows_source::open_wavein_device(void) CALLBACK_FUNCTION | WAVE_ALLOWSYNC); if (result) { - GR_LOG_ERROR( - d_logger, - boost::format("Failed to open waveform output device: %s" % strerror(errno))); + GR_LOG_ERROR(logger, + boost::format("Failed to open waveform output device: %s") % + strerror(errno)); return -1; } return 0; @@ -331,9 +336,10 @@ static void CALLBACK read_wavein( // Ignore WIM_OPEN and WIM_CLOSE messages if (uMsg == WIM_DATA) { if (!dwInstance) { - GR_LOG_ERROR(d_logger, - boost::format("callback function missing buffer queue: %s" % - strerror(errno))); + gr::logger_ptr logger; + GR_LOG_ERROR(logger, + boost::format("callback function missing buffer queue: %s") % + strerror(errno)); } LPWAVEHDR lp_wave_hdr = (LPWAVEHDR)dwParam1; // The new audio data boost::lockfree::spsc_queue<LPWAVEHDR>* q = |