summaryrefslogtreecommitdiff
path: root/gr-video-sdl/lib/sink_s_impl.cc
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2020-04-11 01:19:03 +0200
committerMarcus Müller <marcus@hostalia.de>2020-04-13 15:55:41 +0200
commit916739a20e33ab9323947f17b28d9eb256e498a0 (patch)
treeb662e57dcf13df47a4f84202df63d387b54cddea /gr-video-sdl/lib/sink_s_impl.cc
parent2a09931c72c58d1d5bd6f6860c13ecf39154ea3d (diff)
video-sdl: replace stderr logging by calls to GR's logging facilties
Diffstat (limited to 'gr-video-sdl/lib/sink_s_impl.cc')
-rw-r--r--gr-video-sdl/lib/sink_s_impl.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/gr-video-sdl/lib/sink_s_impl.cc b/gr-video-sdl/lib/sink_s_impl.cc
index 26eefac649..18bbb94814 100644
--- a/gr-video-sdl/lib/sink_s_impl.cc
+++ b/gr-video-sdl/lib/sink_s_impl.cc
@@ -76,8 +76,10 @@ sink_s_impl::sink_s_impl(double framerate,
atexit(SDL_Quit); // check if this is the way to do this
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
- std::cerr << "video_sdl::sink_s: Couldn't initialize SDL:" << SDL_GetError()
- << " \n SDL_Init(SDL_INIT_VIDEO) failed\n";
+ std::ostringstream msg;
+ msg << "Couldn't initialize SDL:" << SDL_GetError()
+ << "; SDL_Init(SDL_INIT_VIDEO) failed";
+ GR_LOG_ERROR(d_logger, msg.str());
throw std::runtime_error("video_sdl::sink_s");
};
@@ -90,8 +92,10 @@ sink_s_impl::sink_s_impl(double framerate,
SDL_ANYFORMAT); // SDL_DOUBLEBUF |SDL_SWSURFACE| SDL_HWSURFACE||SDL_FULLSCREEN
if (d_screen == NULL) {
- std::cerr << "Unable to set SDL video mode: " << SDL_GetError()
- << "\n SDL_SetVideoMode() Failed \n";
+ std::ostringstream msg;
+ msg << "Unable to set SDL video mode: " << SDL_GetError()
+ << "; SDL_SetVideoMode() Failed";
+ GR_LOG_ERROR(d_logger, msg.str());
exit(1);
}
if (d_image) {
@@ -101,12 +105,16 @@ sink_s_impl::sink_s_impl(double framerate,
/* Initialize and create the YUV Overlay used for video out */
if (!(d_image =
SDL_CreateYUVOverlay(d_width, d_height, SDL_YV12_OVERLAY, d_screen))) {
- std::cerr << "SDL: Couldn't create a YUV overlay: \n" << SDL_GetError() << "\n";
+ std::ostringstream msg;
+ msg << "Couldn't create a YUV overlay: " << SDL_GetError();
+ GR_LOG_ERROR(d_logger, msg.str());
throw std::runtime_error("video_sdl::sink_s");
}
- printf("SDL screen_mode %d bits-per-pixel\n", d_screen->format->BitsPerPixel);
- printf("SDL overlay_mode %i \n", d_image->format);
+ GR_LOG_INFO(d_debug_logger,
+ boost::format("SDL screen_mode %d bits-per-pixel") %
+ d_screen->format->BitsPerPixel);
+ GR_LOG_INFO(d_debug_logger, boost::format("SDL overlay_mode %i") % d_image->format);
d_chunk_size = std::min(1, 16384 / width); // width*16;
d_chunk_size = d_chunk_size * width;
@@ -121,7 +129,9 @@ sink_s_impl::sink_s_impl(double framerate,
// clear the surface to grey
if (SDL_LockYUVOverlay(d_image)) {
- std::cerr << "SDL: Couldn't lock YUV overlay: \n" << SDL_GetError() << "\n";
+ std::ostringstream msg;
+ msg << "Couldn't lock a YUV overlay:" << SDL_GetError();
+ GR_LOG_ERROR(d_logger, msg.str());
throw std::runtime_error("video_sdl::sink_s");
}
@@ -307,10 +317,11 @@ int sink_s_impl::work(int noutput_items,
}
break;
default: // 0 or more then 3 channels
- std::cerr << "video_sdl::sink_s: Wrong number of channels: ";
- std::cerr
- << "1, 2 or 3 channels are supported.\n Requested number of channels is "
- << input_items.size() << "\n";
+ std::ostringstream msg;
+ msg << "Wrong number of channels: 1, 2 or 3 channels are supported. Requested "
+ "number of channels is "
+ << input_items.size();
+ GR_LOG_ERROR(d_logger, msg.str());
throw std::runtime_error("video_sdl::sink_s");
}